<template>
	<view style="background-color: #fff;">
		<!-- #ifndef MP -->
		<view class="sys-head" :style="{ height: statusBarHeight }"></view>
		<!-- #endif -->
		<view class="content">
			<view class="acea-row row-top row-between title">
				<view class="">
					<view class="title-black">{{ !dataform.id ? '添加':'编辑'}}期望业务</view>
					<view class="title-gray">期望业务不同 推荐也会不同</view>
				</view>
			</view>
		</view>
		<view class="list">
			<view class="acea-row row-middle row-between item border-b ">
				<view class="label label-m">
					业务
				</view>
				<view class="acea-row row-middle row-right item-r sanjiao-right"
					@click="!dataform.id ? openPicker('dataMatch') : ''">
					<input class="input-r" type="text" v-model="dataMatch" name='floor' placeholder="请选择业务模板"
						placeholder-class="placeholder-class" disabled>
				</view>
			</view>
			<!-- 求租 -->
			<block v-if="curTemplate.rent">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						{{dataform.dataMatch == 8?'租金':'租金范围'}}
					</view>
					<view class="acea-row row-middle row-right item-r" v-if="dataform.dataMatch == 8">
						<input class="input-r" type="number" placeholder="请输入租金" placeholder-class="placeholder-class"
							v-model="dataform.rentRange" />
						<text style="margin-left: 10rpx;">元/月</text>
					</view>
					<view class="acea-row row-middle row-right item-r floor" v-else>
						<input type="number" v-model="dataform.rentRange">
						<view>~</view>
						<input type="number" v-model="dataform.rentRanges">
						<view class="">元</view>
					</view>
				</view>
			</block>

			<!-- 求租 求购 -->
			<block v-if="curTemplate.area">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						{{[7,8].includes(dataform.dataMatch)?'面积':'面积范围'}}
					</view>
					<view class="acea-row row-middle row-right item-r" v-if="[7,8].includes(dataform.dataMatch)">
						<input class="input-r" type="text" v-model="dataform.areaRange" name='floor' placeholder="请输入面积"
							placeholder-class="placeholder-class">
						<text style="margin-left: 10rpx;">m²</text>
					</view>
					<view class="acea-row row-middle row-right item-r floor" v-else>
						<input type="number" v-model="dataform.areaRange">
						<view>~</view>
						<input type="number" v-model="dataform.areaRanges">
						<view class="">㎡</view>
					</view>
				</view>
			</block>

			<!-- 求购 -->
			<block v-if="curTemplate.sellAmount">
				<view class="acea-row row-middle row-between item border-b">
					<view class="label label-m">
						{{dataform.dataMatch == 7?'金额':'投资金额'}}
					</view>
					<view class="acea-row row-middle row-right item-r floor" v-if="dataform.dataMatch == 7">
						<input type="number" v-model="dataform.serviceAmount">
						<view>~</view>
						<input type="number" v-model="dataform.servicesAmount">
						<view class="">万元</view>
					</view>
					<view class="acea-row row-middle row-right item-r floor" v-else>
						<input type="number" v-model="dataform.sellAmount">
						<view>~</view>
						<input type="number" v-model="dataform.sellsAmount">
						<view class="">元</view>
					</view>
				</view>
			</block>
			<!-- 供应服务 -->
			<block v-if="curTemplate.servicePrice">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						服务价格
					</view>
					<view class="acea-row row-middle row-right item-r floor">
						<input type="number" v-model="dataform.serviceAmount">
						<view>~</view>
						<input type="number" v-model="dataform.servicesAmount">
						<view class="">元</view>
					</view>
				</view>
			</block>
			<block v-if="curTemplate.serviceCategory">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						服务类别
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right" @click="openPicker('serviceType')">
						<input class="input-r" type="text" placeholder="请选择服务类别" placeholder-class="placeholder-class"
							v-model="serviceType" disabled />
					</view>
				</view>
			</block>

			<!-- 求职 -->
			<block v-if="curTemplate.experience">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						经验
					</view>
					<view class="acea-row row-middle row-right item-r floor" v-if="dataform.dataMatch == 6">
						<input type="number" v-model="dataform.experiences">
						<view>~</view>
						<input type="number" v-model="dataform.exper">
						<view class="">年</view>
					</view>
					<view class="acea-row row-middle row-right item-r" v-else>
						<input class="input-r" type="text" placeholder="请选择输入经验" placeholder-class="placeholder-class"
							v-model="dataform.experiences" />
						<text>年</text>
					</view>

				</view>
			</block>
			<!-- 招工 求职 -->
			<block v-if="curTemplate.expectationAmount || curTemplate.salary">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						{{ curTemplate.expectationAmount? '金额': '期望薪资' }}
					</view>
					<view class="acea-row row-middle row-right item-r floor">
						<input type="number" v-model="dataform.wages">
						<view>~</view>
						<input type="number" v-model="dataform.wage">
						<view class="">万元</view>
					</view>
				</view>
			</block>
			<block v-if="curTemplate.Indus">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						所属行业
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right" @click="openPicker('industry')">
						<input class="input-r" type="text" placeholder="请选择所属行业" placeholder-class="placeholder-class"
							v-model="industry" />
					</view>
				</view>
			</block>
			<block v-if="curTemplate.post">
				<view class="uni-form-item uni-column">
					<view class="acea-row row-middle row-between item border-b ">
						<view class="label label-m">
							职位
						</view>
						<view class="acea-row row-middle row-right item-r sanjiao-right" @click="openJob">
							<input class="input-r" type="text" placeholder="请选择一个期望职位"
								placeholder-class="placeholder-class" v-model="dataform.position" />
						</view>
					</view>
				</view>
			</block>
			<block v-if="curTemplate.type">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						招工类型
					</view>
					<view class="acea-row row-middle row-right item-r radio-list">
						<view class="acea-row row-middle radio-item" @click="dataform.types = 0;$forceUpdate()">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.types == 0"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">全职</view>
						</view>
						<view class="acea-row row-middle radio-item margin-l"
							@click="dataform.types = 1;$forceUpdate()">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.types == 1"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">兼职</view>
						</view>
					</view>
				</view>
			</block>
			<!-- 招工 -->
			<!-- 			<block v-if="dataform.dataMatch == 6">
				<view class="uni-form-item uni-column">
					<view class="acea-row row-middle row-between item border-b ">
						<view class="label">
							经验要求
						</view>
						<view class="acea-row row-middle row-right item-r floor">
							<input type="number" v-model="dataform.experiences">
							<view>~</view>
							<input type="number" v-model="dataform.exper">
							<view class="">年</view>
						</view>
					</view>
				</view>
			</block> -->
			<!-- 出租 出售 供应服务 -->
			<block v-if="curTemplate.hopeArea">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						区域
					</view>
					<view class="item-r sanjiao-right" @click="openBusinessFormat('serviceArea')">
						<input class="input-r" type="text" placeholder="请选择区域" placeholder-class="placeholder-class"
							v-model="regionName" disabled />
					</view>
				</view>
			</block>
			<!-- 出租 出售 求购 -->
			<block v-if="curTemplate.property">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						{{ (dataform.dataMatch != 1) || (dataform.dataMatch == 8) ? '店铺类型':'物业类型'}}
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right" @click="openPicker('propertys')">
						<input class="input-r" type="text" placeholder="请选择" placeholder-class="placeholder-class"
							v-model="propertys" disabled />
					</view>
				</view>
			</block>
			<!-- 求租 出租 出售 -->
			<block v-if="curTemplate.operation">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						经营类型
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right"
						@click="openBusinessFormat('groupCurrent')">
						<input class="input-r" type="text" v-model="businessForm" name='floor' placeholder="请选择经营类型"
							placeholder-class="placeholder-class" disabled>
					</view>
				</view>
			</block>
			<!-- 出租 出售 -->
			<!-- 			<block v-if="[7,8].includes(dataform.dataMatch)">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						面积
					</view>
					<view class="acea-row row-middle row-right item-r">
						<input class="input-r" type="text" v-model="dataform.areaRange" name='floor' placeholder="请输入面积"
							placeholder-class="placeholder-class">
						<text style="margin-left: 10rpx;">m²</text>
					</view>
				</view>
			</block> -->
			<!-- 出售 -->
			<!-- 			<block v-if="dataform.dataMatch == 7">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						金额
					</view>
					<view class="acea-row row-middle row-right item-r floor">
						<input type="number" v-model="dataform.serviceAmount">
						<view>~</view>
						<input type="number" v-model="dataform.servicesAmount">
						<view class="">万元</view>
					</view>
				</view>
				</block> -->
			<block v-if="curTemplate.rate">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						投资回报率
					</view>
					<view class="acea-row row-middle row-right item-r floor">
						<input type="number" v-model="dataform.userRate">
						<view>~</view>
						<input type="number" v-model="dataform.userRates">
						<view class="">%</view>
					</view>
				</view>
			</block>
			<!-- 出租 招工 供应服务 -->
			<block v-if="[1,2,3,4,5,6,8].includes(dataform.dataMatch) && curTemplate.keword">
				<!-- 配套要求 -->
				<view class="module">
					<view class="acea-row row-middle row-between">
						<view class="module-title label-m">
							{{ dataform.dataMatch == 8 ? '配套要求' : '关键字'}}
						</view>
						<view class="add-advantage red-sanjiao-r" @click="addAd">
							没找到合适的？选择自定义
						</view>
					</view>
					<view class="acea-row advantage-list">
						<view class="itemBox" v-for="(item,index) in advantages" :key="index">
							<icon type="cancel" color="#000" size="14" @click="closeAdvantages(item,index)"
								class="close" />
							<view class="item" :class="advantageIds.indexOf(item)!=-1?'item-on':''"
								@click="advantageChecked(item,index)">{{item}}</view>
						</view>
					</view>
				</view>
			</block>
			<!-- 出租 求购 -->
			<block v-if="curTemplate.supporting">
				<view class="acea-row row-middle row-between item border-b">
					<view class="label label-m">配套设施</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right" @click="opendiction(15,'supp')">
						<input class="input-r" type="text" placeholder="请选择配套设施" placeholder-class="placeholder-class"
							v-model="supp" disabled />
					</view>
				</view>
			</block>
			<!-- 出租 -->
			<!-- 			<block v-if="dataform.dataMatch == 8">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						租金
					</view>
					<view class="acea-row row-middle row-right item-r">
						<input class="input-r" type="number" placeholder="请输入租金" placeholder-class="placeholder-class"
							v-model="dataform.rentRange" />
						<text style="margin-left: 10rpx;">元/月</text>
					</view>
				</view>
			</block> -->
			<block v-if="curTemplate.storeType">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						店面类型
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right"
						@click="opendiction(21,'storesType')">
						<input class="input-r" type="text" placeholder="请选择店铺类型" placeholder-class="placeholder-class"
							v-model="storesType" disabled />
					</view>
				</view>
			</block>
			<block v-if="curTemplate.pavementType">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						铺面类型
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right"
						@click="opendiction(17,'pavementsType')">
						<input class="input-r" type="text" placeholder="请选择店铺类型" placeholder-class="placeholder-class"
							v-model="pavementsType" disabled />
					</view>
				</view>
			</block>
			<block v-if="curTemplate.routeType">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						临路类型
					</view>
					<view class="acea-row row-middle row-right item-r sanjiao-right"
						@click="opendiction(16,'routesType')">
						<input class="input-r" type="text" placeholder="请选择店铺类型" placeholder-class="placeholder-class"
							v-model="routesType" disabled />
					</view>
				</view>
			</block>
			<!-- 电梯 -->
			<block v-if="curTemplate.elevator">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label">
						电梯
					</view>
					<view class="acea-row row-middle row-right item-r radio-list">
						<view class="acea-row row-middle radio-item" @click="dataform.elevators=1">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.elevators==1"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">有</view>
						</view>
						<view class="acea-row row-middle radio-item margin-l" @click="dataform.elevators=0">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.elevators==0"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">无</view>
						</view>
					</view>
				</view>
			</block>
			<!-- 装修 -->
			<block v-if="curTemplate.renovation">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						装修
					</view>
					<view class="acea-row row-middle row-right item-r radio-list">
						<view class="acea-row row-middle radio-item" @click="dataform.renovations=1">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.renovations==1"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">有</view>
						</view>
						<view class="acea-row row-middle radio-item margin-l" @click="dataform.renovations=0">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.renovations==0"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">无</view>
						</view>
					</view>
				</view>
			</block>
			<!-- 性别 -->
			<block v-if="curTemplate.gender">
				<view class="acea-row row-middle row-between item border-b ">
					<view class="label label-m">
						性别
					</view>
					<view class="acea-row row-middle row-right item-r radio-list">
						<view class="acea-row row-middle radio-item" @click="dataform.genders=1">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.genders==1"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">男</view>
						</view>
						<view class="acea-row row-middle radio-item margin-l" @click="dataform.genders=2">
							<image src="../static/images/radio_on.png" mode="" v-if="dataform.genders==2"></image>
							<image src="../static/images/radio_no.png" mode="" v-else></image>
							<view class="">女</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<u-picker :show="pickerShow" :columns="columns" :keyName="keyName" @confirm="confirm"
			@cancel="pickerShow = false" @change="changeHandler" :defaultIndex="defaultIndex"></u-picker>
		<dictionaryType ref="dictionaryType" :gids='gids' @clickOk='clickOk' v-if="openPopupShow" :key="gids"
			:popupShow='openPopupShow' @popupClose="openPopupShow = false" />
		<view class="acea-row padding20">
			<view class="del_btn" v-if="dataform.dataMatch && dataform.id" @click="deletes">
				删除
			</view>
			<view class="save_btn" v-if="dataform.dataMatch" @click="submitForm">
				保存
			</view>
		</view>
		<view class="uni-p-b-98"></view>
		<manage ref="groupCurrent" @confrim="currentConfrim"></manage>
		<serviceArea ref="serviceArea" dataType="area" @area="handleArea" :multiple="false" />
		<addKeyWord ref="addKeyWord" @addConfirm="addConfirm" />
		<!-- 选择职位 -->
		<selectJob v-model="dataform.position" ref="job" :multiple="false" />
	</view>
</template>

<script>
	import {
		DateMatchListApi,
		UserMatchAddApi,
		UserMatchUpdateApi,
		DateMatchDeteleApi,
		getActiveTemplate
	} from '@/api/template.js'
	import {
		dictionary
	} from "@/api/subletOfShop.js"
	import manage from "../components/manage.vue"
	import selectJob from '../components/selectJob.vue';
	import dictionaryType from '../components/dictionaryType.vue'
	import serviceArea from '../components/area.vue';
	import addKeyWord from '../components/addKeyWord/addKeyWord.vue'
	import {
		getTypeApi
	} from "@/api/api.js";
	import {
		getIndustryListApi
	} from '@/api/recruit.js'
	var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
	export default {
		components: {
			manage,
			serviceArea,
			dictionaryType,
			addKeyWord,
			selectJob
		},
		onLoad(option) {
			this.getActTemp();
			if (!option.item) return
			console.log(JSON.parse(option.item))
			let item = JSON.parse(option.item)
			this.dataform = item;
			this.advantageIds = item.kewords.split(',');
			this.businessForm = item.businessFormName;
			this.propertys = item.propertysName;
			this.regionName = item.disName;
			this.pavementsType = item.pavementsTypeName;
			this.routesType = item.routesTypeName;
			this.storesType = item.storesTypeName;
			this.supp = item.suppName;
			this.dataMatch = item.dataMatchName;
			this.industry = item.industryName
			this.serviceType = item.serviceTypeName;

		},

		data() {
			return {
				defaultIndex: [0],
				industryList: [], //行业列表
				statusBarHeight: statusBarHeight,
				dateMatchList: [], //模板列表
				dataMatch: '',
				pickerShow: false,
				columns: [],
				dataform: {
					types: 0,
					elevators: 0,
					renovations: 0,
					genders: 1
				},
				pickerType: '',
				keyName: '',
				businessForm: '', //经营类型名称
				regionName: '', //期望区域名称
				openPopupShow: false,
				gids: null,
				supp: '', //配套设施
				advantages: ['免租一个月', '天然气', '中央空调', '临街门面', '暖气', '排烟', '热水器', '可明火', '排污', '上水'], //店铺优势
				advantageIds: [],
				propertys: '',
				routesType: '',
				pavementsType: '',
				params: '',
				storesType: '',
				industry: '', //所属行业名称
				serviceType: '', //服务类别名称
				serviseList: [],
				activeTemplate: [],
				curTemplate: {}
			}
		},
		onShow() {
			if(this.item){
				this.getDateMatchList();
			}
			this.getDictionary(14);
			this.getIndustryList();
			this.getServiceType();
		},
		methods: {
			async getDictionary(gids) {
				try {
					let {
						data
					} = await dictionary({
						gids
					});
					this.propertyList = data['14']
				} catch (e) {
					//TODO handle the exception
				}
			},
			async getServiceType() {
				try {
					let {
						data
					} = await getTypeApi({
						limit: 9999
					});
					this.serviseList = data.list
				} catch (e) {
					//TODO handle the exception
				}
			},
			async getDateMatchList() {
				try {
					let {
						data
					} = await DateMatchListApi({
						limit: 10
					});
					// console.log(data)
					this.dateMatchList = data;
					if (this.dataMatch) {
						this.dateMatchList.forEach(item => {
							if (item.nameModl == this.dataMatch) {
								this.setCurTemp(item.id)
							}
						})

					}
				} catch (e) {
					//TODO handle the exception
				}
			},
			//去选择期望职位
			openJob() {
				this.$refs.job.filtrateShow = true;
			},
			//行业列表
			async getIndustryList() {
				try {
					let {
						data
					} = await getIndustryListApi();
					this.industryList = data;
				} catch (e) {
					//TODO handle the exception
				}
			},
			//picker滚动触发
			changeHandler(e) {
				if (['salary'].includes(this.pickerType) && e.columnIndex === 0) {
					let dbArray = [];
					for (let i = 0; i < 7; i++) {
						dbArray[i] = i;
						dbArray[i] += 1;
					}
					let type = this.pickerType == 'salary' ? 'K' : '年'
					let num = e.value[0] ? e.value[0].split(type)[0] : 0;
					for (let i = 0; i < dbArray.length; i++) {
						dbArray[i] += Number(num);
						dbArray[i] += type
					}
					// this.columns[1] = dbArray;
					this.$set(this.columns, 1, dbArray)
					this.$forceUpdate()

				} else if (['serviceType', 'industry'].includes(this.pickerType) && e.columnIndex == 0) {
					// this.columns = this.pickerType == 'industry' ? [this.industryList, this.industryList[e.index].children] : 
					// 	[this.serviseList, this.serviseList[e.index].children ? this.serviseList[e.index].children : []];
					this.$forceUpdate()
					this.columns = [this.serviseList, this.serviseList[e.index].children ? this.serviseList[e.index]
						.children : []
					]
					console.log(this.serviseList[e.index].children ? this.serviseList[e.index].children : [])

				}
			},
			//打开选择器
			openPicker(params) {
				this.pickerType = params
				switch (params) {
					case 'dataMatch':
						this.columns = [this.dateMatchList];
						this.keyName = 'nameModl'
						this.defaultIndex = [0]
						break;
					case 'propertys':
						this.columns = [this.propertyList];
						this.keyName = 'name'
						this.defaultIndex = [0]
						break;
					case 'industry':
						this.columns = [this.industryList, this.industryList[0].children];
						this.keyName = 'name';
						this.defaultIndex = [0, 0]
						break;
					case 'serviceType':
						this.columns = [this.serviseList, this.serviseList[0].children];
						this.keyName = 'name';
						this.defaultIndex = [0, 0]
						break;
				}
				this.pickerShow = true
			},

			confirm(e) {
				this.pickerShow = false;
				if (['salary'].includes(this.pickerType)) {
					this.dataform[this.pickerType] = e.value[0] + (e.value[1] ? ('~' + e.value[1]) : '');
				} else {
					this[this.pickerType] = e.value[1] ? e.value[1][this.keyName] : e.value[0][this.keyName];
					this.dataform[this.pickerType] = e.value[1] ? e.value[1].id : e.value[0].id;
				}

				if (this.pickerType == 'dataMatch') {
					this.setCurTemp(this.dataform[this.pickerType])
				}
				// console.log(this.pickerType)

				this.$forceUpdate();
			},
			setCurTemp(id) {
				this.activeTemplate.forEach(item => {
					if (item.id == id) {
						this.curTemplate = item;
						console.log('curTemplate', this.curTemplate)
					}
				})
			},
			//打开经营多选框
			openBusinessFormat(ref) {
				this.$refs[ref].filtrateShow = true
			},
			//确认选择当前经营后触发
			currentConfrim(val) {
				this.dataform.businessForm = val.selectedIds;
				this.businessForm = val.name;
			},
			//期望区域
			handleArea(areaInfo) {
				this.dataform.dis = areaInfo.districtIds;
				this.regionName = areaInfo.regionName;
			},
			//字典
			opendiction(val, params) {
				this.openPopupShow = true;
				this.params = params
				// 配套设施
				this.gids = val
			},
			clickOk(val) {
				this.dataform[this.params] = val.map(item => {
					return item.id
				}).join(',')
				this[this.params] = val.map(item => {
					return item.name
				}).join(',')

				this.openPopupShow = false
			},
			//添加配套要求
			addAd() {
				this.$refs.addKeyWord.popupShow = true
			},
			addConfirm(e) {
				this.advantages=this.advantages.concat(e)
			},
			//删除标签
			closeAdvantages(item, index) {
				this.advantages.splice(index, 1)
				if (this.advantageIds.indexOf(index) != -1) {
					let idx = this.advantageIds.indexOf(index)
					this.advantageIds.splice(idx, 1);
				}
			},
			advantageChecked(item) {
				if (this.advantageIds.indexOf(item) != -1) {
					let idx = this.advantageIds.indexOf(item);
					this.advantageIds.splice(idx, 1);
				} else {
					this.advantageIds.push(item);
				}
			},
			async submitForm() {
				let that = this;
				this.dataform.kewords = this.advantageIds.join(',');
				if (that.dataform.dataMatch == 1) {
					// if (!that.dataform.rentRange || !that.dataform.rentRanges) return that.$util.Tips({
					// 	title: '请输入租金范围'
					// });
				}
				if (that.dataform.dataMatch == 2) {
					if (!that.dataform.experiences) return that.$util.Tips({
						title: '请输入经验'
					});
				}
				if ([1, 3].includes(that.dataform.dataMatch)) {
					if (!that.dataform.areaRange || !that.dataform.areaRanges) return that.$util.Tips({
						title: '请输入面积范围'
					});
					if (!that.dataform.kewords) return that.$util.Tips({
						title: '请选择关键字'
					});

				}
				if (that.dataform.dataMatch == 3) {
					if (!that.dataform.sellAmount || !that.dataform.sellsAmount) return that.$util.Tips({
						title: '请输入投资金额范围'
					});
				}
				if ([1, 3, 8].includes(that.dataform.dataMatch)) {
					if (!that.dataform.supp) return that.$util.Tips({
						title: '请选择配套设施'
					});
				}
				if ([2, 6].includes(that.dataform.dataMatch)) {
					if (!that.dataform.wages || !that.dataform.wage) return that.$util.Tips({
						title: '请输入' + that.dataform.dataMatch == 6 ? '金额' : '期望薪资'
					});
					if (that.dataform.industry=='') return that.$util.Tips({
						title: '请选择所属行业'
					});
					if (!that.dataform.position) return that.$util.Tips({
						title: '请选择一个期望职位'
					});

				}
				if (that.dataform.dataMatch == 6) {
					if (!that.dataform.experiences || !that.dataform.exper) return that.$util.Tips({
						title: '请输入经验要求'
					});
				}
				if ([4, 5].includes(that.dataform.dataMatch)) {
					if (!that.dataform.serviceAmount || !that.dataform.servicesAmount) return that.$util.Tips({
						title: '请输入服务价格'
					});
					if (!that.dataform.serviceType || !that.dataform.serviceType) return that.$util.Tips({
						title: '请选择服务类别'
					});
				}
				if ([4, 5, 7, 8].includes(that.dataform.dataMatch)) {
					if (that.dataform.dis=='') return that.$util.Tips({
						title: '请选择区域'
					});
				}
				if ([1, 3, 7, 8].includes(that.dataform.dataMatch)) {
					if (!that.dataform.propertys) return that.$util.Tips({
						title: '请选择店铺类型'
					});
				}
				if ([1, 7, 8].includes(that.dataform.dataMatch)) {
					if (that.dataform.businessForm=='') return that.$util.Tips({
						title: '请选择业态'
					});
				}
				if ([7, 8].includes(that.dataform.dataMatch)) {
					if (!that.dataform.areaRange) return that.$util.Tips({
						title: '请输入面积'
					});
				}
				if ([4, 5, 6, 8].includes(that.dataform.dataMatch)) {
					if (!that.dataform.kewords) return that.$util.Tips({
						title: '请选择' + (that.dataform.dataMatch == 8 ? '配套要求' : '关键字')
					});
				}
				if (that.dataform.dataMatch == 7) {
					if (!that.dataform.serviceAmount || !that.dataform.servicesAmount) return that.$util.Tips({
						title: '请输入金额'
					});
					if (!that.dataform.userRate || !that.dataform.userRates) return that.$util.Tips({
						title: '请输入投资回报率'
					});
				}
				if (that.dataform.dataMatch == 8) {
					if (!that.dataform.rentRange) return that.$util.Tips({
						title: '请输入租金'
					});
					if (!that.dataform.storesType) return that.$util.Tips({
						title: '请选择店面类型'
					});
					if (!that.dataform.pavementsType) return that.$util.Tips({
						title: '请选择铺面类型'
					});
					if (!that.dataform.routesType) return that.$util.Tips({
						title: '请选择临路类型'
					});
				}
				let name = '';
				switch (this.dataform.dataMatch) {
					case 2:
						name = this.industry
						break;
					case 6:
						name = this.dataform.position
						break;
					case 5:
						name = this.serviceType
						break;
					case 4:
						name = this.serviceType
						break;
					default:
						name = this.dataform.areaRange + '㎡' + this.propertys
						break;
				}


				this.dataform.name = this.dataMatch + name
				try {
					this.dataform.id ? await UserMatchUpdateApi(this.dataform) :
						await UserMatchAddApi(this.dataform)
					this.operationCompleted()
				} catch (e) {
					console.log(e)
					//TODO handle the exception
				}
			},
			async deletes() {
				try {
					let res = await DateMatchDeteleApi(this.dataform.id)
					this.operationCompleted()
				} catch (e) {
					//TODO handle the exception
				}
			},
			operationCompleted() {
				this.$util.Tips({
					title: '操作完成'
				});
				setTimeout(() => {
					uni.navigateBack()
				}, 2000)

			},
			//获取动态模板
			getActTemp(type) {
				getActiveTemplate().then(res => {
					console.log("dt", res, res.code == 200)
					if (res.code == 200) {
						console.log(123)
						this.activeTemplate = res.data;
						this.getDateMatchList()
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 26rpx;
	}

	.title {
		margin-bottom: 50rpx;

		.title-black {
			font-size: 48rpx;
			font-weight: 700;
			color: rgba(0, 0, 0, 1);
		}

		.title-gray {
			font-size: 26rpx;
			font-weight: 400;
			color: rgba(128, 128, 128, 1);
			margin-top: 10rpx;
		}
	}

	.del_btn {
		height: 82rpx;
		line-height: 82rpx;
		border: 2rpx solid rgba(238, 33, 45, 1);
		margin: 50rpx 25rpx 50rpx 0;
		padding: 0 30rpx;
		border-radius: 15rpx;
		text-align: center;
		color: rgba(238, 33, 45, 1);
		font-size: 32rpx;

	}

	.save_btn {
		height: 82rpx;
		line-height: 82rpx;
		background-color: rgba(238, 33, 45, 1);
		flex: 1;
		margin: 50rpx auto;
		border-radius: 15rpx;
		text-align: center;
		color: #fff;
		font-size: 32rpx;
	}

	@import '/static/css/releaseForm.css';
</style>